Hello DOORS users
#include <utils/ole.inc>
Anyone can tell me why I got this error ?
Thank you
#include <utils/ole.inc>
// Open a file in Excel
OleAutoObj openExcelFile(string sFileName, bool bVisible)
{
OleAutoObj oleWorkbooks = null
OleAutoObj oleExcel = null
OleAutoArgs autoArgs = create
oleExcel = oleGetAutoObject("Excel.Application")
if (null oleExcel)
{
oleExcel = oleCreateAutoObject("Excel.Application")
if(null oleExcel)
{
errorBox("Unable to open excel application")
}
olePut (oleExcel, "Visible", bVisible)
// Get workbooks and open file
clear autoArgs
oleGet(oleExcel,"Workbooks", oleWorkbooks)
put(autoArgs,"Filename", sFileName)
oleMethod(oleWorkbooks,"Open",autoArgs)
}
delete autoArgs
return oleExcel
}
//Get the worksheets
OleAutoObj excelGetWorksheet(OleAutoObj oleExcel, int iSheetNumber)
{
OleAutoObj objExcelSheet = null
string sSheetNumber = "Sheet" iSheetNumber ""
OleAutoArgs autoArgs = create
put(autoArgs ,sSheetNumber)
oleGet(oleExcel,"WorkSheets",autoArgs ,objExcelSheet)
delete autoArgs
return objExcelSheet
}
string getCellValue(OleAutoObj objExcelSheet, int iRow, int iCol)
{
string sValue = null
OleAutoObj objCell = null
OleAutoArgs autoArgs = create
put(autoArgs,iRow)
put(autoArgs,iCol)
oleGet(objExcelSheet,"Cells",autoArgs,objCell)//error here
if (!null objCell)
{
// Get the value
oleGet(objCell,"Value",sValue)
}
delete autoArgs
return sValue
}
//close excel
void excelQuit(OleAutoObj oleExcel)
{
oleMethod(oleExcel, "Quit")
oleCloseAutoObject(oleExcel)
}
// Main
string path="C:/User/E376407/SPHUILE.xls"
OleAutoObj oleExcel = openExcelFile(path,true)
OleAutoObj objExcelSheet = excelGetWorksheet(oleExcel,1)
string s = null
s = getCellValue(objExcelSheet,3, 3)
print s "Row 1, Column 1: " s "\n"
//s = getCellValue(objExcelSheet, 2, 3)
print s "Row 2, Column 3: " s "\n"
excelQuit(oleExcel)
-R-E- DXL: <Line:50> null OleAutoObj parameter was passed into argument position 1
Backtrace:
<Line:76>
-I- DXL: execution halted
izzo - Thu Mar 24 08:52:07 EDT 2011 |
|
Re: Read data from excel sheet adevicq - Thu Mar 24 09:15:04 EDT 2011
Hi,
I have this method to get a pointer to a sheet:
const string cExcelPropertySheets = "Sheets"
OleAutoObj excelGetSheetOLE( OleAutoObj objExcelWorkbook, int sheetNumber ) {
OleAutoObj objExcelSheet
clear( objArgBlock )
put( objArgBlock, sheetNumber )
oleResult( oleGet( objExcelWorkbook, cExcelPropertySheets, objArgBlock, objExcelSheet ) )
return objExcelSheet
}
Regards,
Alain
|
|
Re: Read data from excel sheet izzo - Thu Mar 24 09:43:06 EDT 2011 adevicq - Thu Mar 24 09:15:04 EDT 2011
Hi,
I have this method to get a pointer to a sheet:
const string cExcelPropertySheets = "Sheets"
OleAutoObj excelGetSheetOLE( OleAutoObj objExcelWorkbook, int sheetNumber ) {
OleAutoObj objExcelSheet
clear( objArgBlock )
put( objArgBlock, sheetNumber )
oleResult( oleGet( objExcelWorkbook, cExcelPropertySheets, objArgBlock, objExcelSheet ) )
return objExcelSheet
}
Regards,
Alain
OK Great it works
The problem was getting the sheet,
I just got a little question for you :
oleResult Where oleResult got from, I do no have it in ole.inc
|
|
Re: Read data from excel sheet adevicq - Thu Mar 24 10:02:24 EDT 2011 izzo - Thu Mar 24 09:43:06 EDT 2011
OK Great it works
The problem was getting the sheet,
I just got a little question for you :
oleResult Where oleResult got from, I do no have it in ole.inc
it seems to be equivalent to
"checkRes"
in
utils\ole.inc
Alain
|
|
Re: Read data from excel sheet izzo - Fri Mar 25 09:39:41 EDT 2011
Yup I found it
Thanks
|
|
Re: Read data from excel sheet muthurani - Mon Oct 22 10:39:14 EDT 2012 izzo - Fri Mar 25 09:39:41 EDT 2011
Yup I found it
Thanks
Hello,
Can you please help me how you include the "excelGetSheetOLE" method in your existing code.
thanks,
Regards,
Rani
|
|
Re: Read data from excel sheet adevicq - Tue Oct 23 03:26:39 EDT 2012 muthurani - Mon Oct 22 10:39:14 EDT 2012
Hello,
Can you please help me how you include the "excelGetSheetOLE" method in your existing code.
thanks,
Regards,
Rani
Hi,
I don't exactly see your point. Here is an example:
OleAutoObj objSheet
int nSheet = 3
// Get active workbook
oleResult( oleGet( objExcelApplication,
cExcelPropertyActiveWorkbook,
objExcelWorkbook ) )
// Get a opinter to the sheet
objSheet = excelGetSheetOLE( objExcelWorkbook, nSheet )
if (objSheet == null) {
}
// etc...
Does it answer your question?
Regards
|
|
Re: Read data from excel sheet muthurani - Tue Oct 23 03:53:59 EDT 2012 adevicq - Tue Oct 23 03:26:39 EDT 2012
Hi,
I don't exactly see your point. Here is an example:
OleAutoObj objSheet
int nSheet = 3
// Get active workbook
oleResult( oleGet( objExcelApplication,
cExcelPropertyActiveWorkbook,
objExcelWorkbook ) )
// Get a opinter to the sheet
objSheet = excelGetSheetOLE( objExcelWorkbook, nSheet )
if (objSheet == null) {
}
// etc...
Does it answer your question?
Regards
Hi,
I am new to DXL. i am having the same requirement for read data from excel. I tried your code and couldnt know how to correct the error which you have mentioned in the thread. Can you please help me. It would be helpful if i get the code.
Thanks in advance,
Rani
|
|
Re: Read data from excel sheet adevicq - Wed Oct 24 03:19:13 EDT 2012 muthurani - Tue Oct 23 03:53:59 EDT 2012
Hi,
I am new to DXL. i am having the same requirement for read data from excel. I tried your code and couldnt know how to correct the error which you have mentioned in the thread. Can you please help me. It would be helpful if i get the code.
Thanks in advance,
Rani
Hi,
Can you tell me what exactly is your objective and what are the problems you mention?
Regards,
Alain
|
|